//轮播图
jQuery.fn.lunbotu = function (data,time){
	//1.生成dom
	var str = '<div class="imgList">';
    var str1 = '<ul class="list">';
	jQuery.each(data,function(i,n){
		str += '<img src="'+n+'">';
        str1 += '<li>'+(i+1)+'</li>';

	});
	str += '</div>';
    str1 += '</ul>';
	$(str).appendTo(this);
    $(str1).appendTo(this);
	//切换逻辑
    var timer = null;
	var current = data.length - 1;
	timer = setInterval($.proxy(function(){
		//显示下一张，隐藏所有
		current = (++current)%data.length;
        num = current;
		$(this).find('img').eq(current)
		.animate({opacity:1},500)
		.siblings().animate({opacity:0},500);
        $(this).find('li').removeClass().eq(current).addClass("active");
	},this),2000);


    $(this).mouseleave(function () {
        var that = this;
        timer = setInterval(function(){
            //显示下一张，隐藏所有
            current = (++current)%data.length;
            $(that).find('img').eq(current).animate({opacity:1},500).siblings().animate({opacity:0},500);
            $(that).find('li').removeClass().eq(current).addClass("active");
        },2000);
    });
    $(this).mouseenter(function () {
        clearInterval(timer);
    });


    $(".list>li").mouseover(function(){
        var index = $(".list li").index(this);
        $(".imgList img").eq(index).animate({opacity:1},500).siblings().animate({opacity:0},500);

        $(".list li").removeClass().eq(index).addClass('active');
        current = index;

    });
};